///iryt.js//获取应用实例
let that;
const app = getApp()
Page({
  data: {
    // sLoged: ''
    aChizi:[...Array(80).keys()].slice(1),
    aGen:[],
    nWanfa: 8,//快乐几
    nGen: 1,
    aHistory:wx.getStorageSync('bought')
  },
  onload(options){
    
  },
  genHao1(){
    this.data.nGen = 1;
    this.genHao();
  },
  genHao5(){
    // this.data.nGen = 5;
    this.genHao();
  },
  genHao(){
    let tempAGen = [];
    let i = this.data.nGen;
    while(i-- > 0){
      this.data.aChizi.sort(() => {return Math.random() - 0.5})
      tempAGen.push([this.data.aChizi.slice(0,this.data.nWanfa).sort((b,c)=>{return b-c})])
    }
    this.setData({aGen:tempAGen})
  },
  buyIt(e){
    let item = e.currentTarget.dataset.item;
    if(item){
      this.setData({aHistory:[item]});
      wx.setStorageSync('bought',[item]);
    }
    
  },
  clearHistory(){
    wx.clearStorage();
    this.setData({aHistory:[]})
  },
  bindWanfaInput(e){
    this.setData({nWanfa:e.detail.value})
  },
  bindNumInput(e){
    this.setData({nGen:e.detail.value})
  }
})